package com.smart4j.framework.thread.impl;

import com.smart4j.framework.thread.Sequence;

/**
 * description: SequenceA 测试 线程之间的变量共享问题 
 * @version v1.0
 * @author w
 * @date 2018年10月10日下午9:53:06
 */
public class SequenceA implements Sequence {

	private static int number = 0;
	
	@Override
	public  int getNumber() {
		number = number + 1 ;
		return number;
	}
	
	public static void main(String[] args) {
		Sequence sequence = new SequenceA();
		ClientThread thread1 = new ClientThread(sequence);
		ClientThread thread2 = new ClientThread(sequence);
		ClientThread thread3 = new ClientThread(sequence);
		// 输出的number值可能是 1-15 , 1-14 等等， number 变量某个瞬间被两个变量同时操作了。
		// number 变量被线程 1-3 共享了 
		thread1.start();
		thread2.start();
		thread3.start();
	}
	
	
	
}
